#include "widget.h"
#include "ui_widget.h"
#include <QPainter>
#include <QPicture>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QPicture pic;
    QPainter painter;
    painter.begin(&pic);
    painter.setPen(QPen(Qt::red));  // 设置画笔颜色
    painter.drawEllipse(QPoint(200, 200), 100, 100);
    painter.end(); // 结束
    pic.save("F:\\qt language test\\104-picture\\tmp.pic");
}

Widget::~Widget()
{
    delete ui;
}

void Widget::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    // 重现绘图指令
    QPicture pic;
    pic.load("F:\\qt language test\\104-picture\\tmp.pic");
    painter.drawPicture(0, 0, pic);
}

